#!/usr/bin/env python


class GameWorld( object ):
    def __init__(self):
        self.entities = []
    
    def addEntity(self, ent):
        self.entities.append( ent )

    def getEntities(self, filter = None):
        if filter is not None:
            return [ e for e in self.entities if filter( e ) ]
        else:
            return self.entities

    def remove(self, ent):
        try:
            self.entities.remove( ent )
        except Exception:
            print("Entity was not registered")
    
_world = GameWorld()

def Entity( entity ):
    _world.addEntity( entity )

def instance(): return _world

__all__ = ['instance', 'entity']